CSEG8003 Course home Portal
UPES · School of Computer Science
CSEG8003 — Modelling and Simulation · L-T-P-C 2-0-1-3
Unit IV
Probability and Statistics for Simulations and Analysis
5 lecture hours · Theory notes · Dr. Mohsin Furkh Dar
CO1CO4 Queues Random noise Variate generation Sensitivity analysis
What this unit gives you

Three practical abilities, in this order:

  1. Analytical benchmarks (queueing formulae) — the known answers against which you verify a simulator.
  2. Input generation — how to manufacture randomness of a required distribution from uniform numbers.
  3. Output interpretation — how much of the result to believe, and which inputs the result actually depends on.

Sections 1–3 are heavily numerical: expect derivations and small calculations in the examination, so practise the worked examples with a calculator.

1. Probability Refresher for Simulation

1.1 Random variables and their descriptors

A random variable X is described by its cumulative distribution function F(x ) = P(Xx), and by its pmf p(x) (discrete) or pdf f(x) (continuous). The descriptors you will use constantly:

E[X] = ∫ xf(x)dx,    Var(X) = E[X2] − (E[X])2,    CV = σ/μ

The coefficient of variation CV is the key number in queueing: it measures variability on a scale that is independent of units, and it is CV, not the mean, that determines how bad a queue becomes.

1.2 Distributions you must know by name and shape

Table 4.1 — Distributions used in simulation input modelling.
Distribution Mean / variance Typical simulation use
Uniform(a,b) (a+b)/2  ;  (ba)2 /12 Complete ignorance between bounds; the source of all other variates
Exponential(λ) 1/λ  ;  1/λ2 (CV = 1) Inter-arrival times of a Poisson process; memoryless service; time to failure
Poisson(λt) λt  ;  λt Number of arrivals in an interval
Erlang(k,λ) / Gamma k/λ  ;  k2 (CV = 1/√k) Service made of k sequential phases; less variable than exponential
Normal(μ,σ2) μ  ;  σ2 Measurement error, sums of many effects; never for a non-negative duration without truncation
Lognormal eμ+σ2/2 Task durations, file sizes, repair times — right-skewed and positive
Weibull(k,λ) λΓ(1+1/k) Reliability and lifetimes with increasing or decreasing hazard rate
Triangular(a,m,b) (a+m+b)/3 Expert opinion when only min, mode and max are known
Empirical From the data itself When you have plenty of measurements and no theoretical form
Common mistake

Using Normal for a service time or an inter-arrival time. The Normal distribution extends to −∞, so it will eventually generate a negative duration, and your simulation will either crash or silently schedule an event in the past. Use lognormal, gamma or a truncated distribution instead.

1.3 Input modelling: fitting a distribution to data

  1. Plot the data — histogram, box plot, time series (to check for trends and non-stationarity).
  2. Choose candidate families from the shape and from physical reasoning.
  3. Estimate parameters (maximum likelihood, or method of moments).
  4. Assess the fit: Q–Q plot, P–P plot, and a goodness-of-fit test — chi-square, Kolmogorov–Smirnov, or Anderson–Darling (which weights the tails, usually the part that matters).
  5. If nothing fits, use the empirical distribution — but then you can never generate a value outside the observed range, which matters for rare events.

2. Introduction to Queues

Definition — Queueing system

A queueing system consists of an arrival process, one or more servers with a service-time distribution, a waiting room of finite or infinite capacity, and a queue discipline that decides which waiting customer is served next.

2.1 Kendall's notation

A queue is described as A/S/c/K/N/D:

So M/M/1 is Poisson arrivals, exponential service, one server, infinite queue, FCFS; M/D/3/10 is Poisson arrivals, constant service, three servers and a waiting room of ten.

2.2 Performance measures and Little's law

Standard notation: λ = arrival rate, μ = service rate per server, ρ = λ/(c μ) = utilisation, L = mean number in system, Lq = mean number in queue, W = mean time in system, Wq = mean waiting time.

Little's law
L = λW   and   Lq = λWq

It holds for any stable queueing system in steady state — any arrival process, any service distribution, any number of servers, any discipline. That generality is what makes it so useful: it converts a measured count into a measured time, and it is the first sanity check to run on simulation output.

2.3 The M/M/1 queue

For ρ = λ/μ < 1 (the stability condition), the steady-state probability of n customers is Pn = (1−ρ)ρn, and:

L = ρ/(1−ρ),    Lq = ρ2 /(1−ρ),    W = 1/(μ−λ),    Wq = ρ/(μ−λ)
Example — a print server

Jobs arrive at λ = 12/hour; mean printing time is 4 minutes, so μ = 15/hour.

  • ρ = 12/15 = 0.8 → the printer is busy 80% of the time.
  • L = 0.8/0.2 = 4 jobs in the system on average.
  • W = 1/(15−12) = 1/3 hour = 20 minutes total.
  • Wq = 20 − 4 = 16 minutes waiting.
  • Check with Little: L = λW = 12 × 1/3 = 4. ✓

Now raise the load to λ = 14: ρ = 0.933, L = 14, W = 60 minutes. A 17% increase in load tripled the queue. That non-linearity is the single most important practical lesson of queueing theory.

2.4 Other standard results

Lq = (λ2σ2 + ρ2) / (2(1−ρ))    =   (ρ2/(1−ρ)) · (1+CV2)/2

Read the second form carefully: with the same mean service time, halving the variability (CV from 1 to 0) halves the queue. Deterministic service (M/D/1) has exactly half the waiting of M/M/1. Variability, not just load, causes congestion — and this is precisely what a simulation captures and a spreadsheet of averages does not.

2.5 Queueing networks and why we simulate

Jackson networks (open, Poisson arrivals, exponential service, probabilistic routing) decompose into independent M/M/c nodes, which is elegant but demands assumptions that real systems violate: finite buffers with blocking, priorities, batch arrivals, correlated inter-arrivals, time-varying rates, balking and reneging, server breakdowns. Once any of these is present the closed form disappears and simulation is the only option. Use the analytical results as verification benchmarks: simulate M/M/1, confirm that the measured L and W match the formulae within the confidence interval, and only then trust the simulator on the harder model.

3. Random Noise

Definition

Noise is the random component of a signal or of a system's behaviour — the part not explained by the deterministic model. In simulation, noise is both something we inject (to model real disturbance) and something we suffer (as sampling error in the output).

3.1 Types of noise by spectrum

Table 4.2 — Noise colours and their character.
Noise Power spectral density Where it appears
White Flat, S(f) ∝ f0 Thermal/Johnson noise, independent measurement error; samples uncorrelated
Pink (1/f) S(f) ∝ 1/f Flicker noise in electronics, network traffic, human-generated processes
Brown/red (random walk) S(f) ∝ 1/f2 Integrated white noise; drift in sensors, Brownian motion, asset prices
Shot Poisson arrivals of discrete quanta Photon or electron counting; packet arrivals
Impulse / burst Rare, large deviations Equipment faults, outliers, switching transients

3.2 Modelling noise in a simulation

Xn+1 = Xn + aΔt + b√(ΔtZ,    Z ~ N(0,1)

Note the √Δt: the noise term scales with the square root of the step, not with the step. Getting this wrong makes the noise magnitude depend on your step size — a classic bug.

3.3 Pseudo-random number generation

Definition

A pseudo-random number generator (PRNG) is a deterministic algorithm xn+1 = g(xn) which, from a seed, produces a sequence un ∈ (0,1) that is statistically indistinguishable from independent uniform draws for the purposes of the simulation.

Required properties: long period (at least the square of the numbers you will consume), good uniformity and independence, high-dimensional equidistribution, speed, small state, reproducibility, and independent substreams for parallel runs (Unit III).

The classical linear congruential generator is xn+1 = (axn + c) mod m, with un = xn/m. It is easy to analyse and easy to get wrong: LCG points fall on a limited number of hyperplanes in d dimensions (Marsaglia's theorem), and the notorious RANDU generator produced only 15 planes in three dimensions, invalidating a generation of published results. Modern practice uses Mersenne Twister (period 219937−1), MRG32k3a (designed for streams), PCG or xoshiro. Testing is done with the TestU01, Dieharder or NIST batteries.

Common mistake

Never use a cryptographic-strength requirement or a language's default `rand()` for serious stochastic simulation without checking its period and quality; and never seed with the clock when you need reproducibility. Every reported result should be accompanied by the generator name, the seed and the substream assignment.

4. Random Variates Generation

Definition

Random variate generation is the process of transforming uniform (0,1) pseudo-random numbers into observations from a specified probability distribution.

4.1 Inverse transform method

If U ~ Uniform(0,1) and F is a cdf, then X = F−1(U) has cdf F.

Proof: P(Xx) = P(F−1(U) ≤ x) = P(UF(x)) = F(x), because F is non-decreasing and U is uniform. ■

Example — exponential variates

F(x) = 1 − e−λx. Set u = 1 − e−λx and solve:

X = −(1/λ) ln(1−U)  ≡  −(1/λ) ln(U)

(The second form is valid because 1−U is also Uniform(0,1); guard against U = 0.) With λ = 0.5 and u = 0.23, x = −2 ln(0.77) = 0.523.

Other inverse-transform cases you should be able to derive on demand:

4.2 Acceptance–rejection method

Used when F−1 has no closed form. Choose a majorising function cg(x) ≥ f(x) where g is easy to sample:

  1. Generate Y ~ g.
  2. Generate U ~ Uniform(0,1).
  3. If Uf(Y)/(cg(Y)) accept X = Y; otherwise reject and repeat.

The expected number of trials per accepted variate is exactly c, so the method is efficient only when the envelope hugs the density.

Example — sampling f(x) = 3x2 on [0,1]

Take g = Uniform(0,1) so g(x) = 1, and c = 3 since max f = 3. Accept Y when UY2. On average three pairs are drawn per accepted value. (Here the inverse transform X = U1/3 is obviously better — which is the point: use rejection only when inversion is unavailable.)

4.3 Special-purpose methods

4.4 Output analysis: making the numbers mean something

Generating the input is half of the statistics; interpreting the output is the other half.

  1. Terminating vs steady-state simulation. A terminating simulation has a natural end (a bank day, one mission); a steady-state simulation studies long-run behaviour and needs a warm-up (transient) period to be discarded — identified with Welch's graphical procedure.
  2. Independent replications. Run n replications with different substreams; the replication means are i.i.d., so the classical confidence interval applies:
± tn−1, 1−α/2 · s/√n
  1. Batch means. For one long steady-state run, split the series into k large batches, treat the batch means as approximately independent, and apply the same formula. Batches must be long enough for the autocorrelation to decay — otherwise the interval is too narrow and you will be over-confident.
  2. Comparing two systems. Build a confidence interval on the difference. If it excludes zero, the difference is significant. Use common random numbers to induce positive correlation and shrink the interval.
  3. Choosing the run length. To reach a target half-width h* from a pilot run of n0 replications with half-width h0, use nn0(h0/h*)2 .
Common mistake

Computing a confidence interval from the individual observations within one run (e.g. the 10 000 customer waiting times). Those are strongly autocorrelated — a long wait is followed by long waits — so the usual formula badly underestimates the variance. Use replications or batch means. This error is common enough that examiners ask about it directly.

5. Sensitivity Analysis

Definition

Sensitivity analysis (SA) is the study of how the variation in a model's output can be apportioned to variation in its inputs — parameters, initial conditions, distributional assumptions and structural choices.

It is distinct from uncertainty analysis, which quantifies how much uncertainty the output has; SA asks where that uncertainty comes from.

5.1 Why it is done

  1. Factor prioritisation — which parameters deserve better measurement?
  2. Factor fixing — which parameters can be frozen at a nominal value, simplifying the model?
  3. Model verification — a parameter that should matter but does not (or vice versa) usually indicates a bug.
  4. Robustness of the recommendation — does the preferred policy remain the best across the plausible parameter range?
  5. Credibility — SA is part of validation and of any serious VV&A report (Units I and V).

5.2 Local (one-factor-at-a-time) sensitivity

Perturb one input around its nominal value and measure the response:

Si = ∂y/∂xi ≈ (y(xi+Δ) − y(xi−Δ)) / (2Δ),    Sirel = (∂y/∂xi )(xi/y)

The relative (elasticity) form is what you should report, because it is dimensionless and comparable across parameters: “a 1% increase in service rate reduces mean wait by 4.6%”.

Limitations: local SA explores a single point of the input space, assumes linearity, and completely misses interactions between factors. For a stochastic simulation, Δ must also be large enough that the response rises above the noise — use common random numbers so that the difference is not swamped by sampling variation.

5.3 Global sensitivity analysis

Global methods vary all inputs simultaneously over their full ranges.

Si = Varxi(E[Y |xi]) / Var(Y),    STi = 1 − Varxi (E[Y|xi]) / Var(Y)

Si is the first-order index (the effect of xi alone); STi is the total index (its effect including all interactions). Interpretation rules worth memorising:

Table 4.3 — Choosing a sensitivity method.
Method Cost (model runs) Use when
Local OAT 2k for k factors Quick check near a nominal design; nearly linear model
Regression / PRCC on LHS Hundreds Monotonic model; want a ranked list quickly
Morris screening r(k+1), r ≈ 10–50 Many factors, need to eliminate the unimportant ones cheaply
Sobol indices N(k+2), N ≈ 103–104 Non-linear model with interactions; a defensible, quantitative attribution is needed
Metamodel-based 102 runs + surrogate Each run costs hours; accept surrogate error in exchange
Example — sensitivity of a queueing model

For M/M/1, W = 1/(μ−λ), so ∂W/∂λ = 1/(μ−λ)2. At λ = 12, μ = 15 the elasticity is (λ/W)∂W/∂λ = λ/(μ−λ) = 4: a 1% rise in arrival rate lengthens the mean sojourn time by 4%. At λ = 14.5 the elasticity is 29. The sensitivity itself depends violently on the operating point — which is exactly why a single local sensitivity number, quoted without its nominal point, is meaningless.

5.4 Reporting sensitivity results

  1. State the nominal values and the assumed range or distribution of every input.
  2. State the output measure and the sampling design used.
  3. Give a tornado diagram (local) or a bar chart of Si and STi (global).
  4. Separate parametric from structural uncertainty — changing a distributional assumption or a model mechanism is not a parameter sweep, and should be reported as an alternative scenario.
  5. Conclude with the decision-relevant statement: which factors must be measured better, which can be ignored, and whether the recommendation is robust.

6. Unit Summary

6.1 Formula sheet

Table 4.4 — Formulae to memorise for the examination.
Quantity Formula
Little's law L = λW; Lq = λWq
M/M/1 utilisation, queue, time ρ = λ/μ; L = ρ/(1−ρ); Lq = ρ2/(1−ρ); W = 1/(μ−λ); Wq = ρ/(μ−λ)
Pollaczek–Khinchine (M/G/1) Lq = ρ2(1+CV2) / (2(1−ρ))
Inverse transform X = F−1(U); exponential: X = −(1/λ)ln U
Acceptance–rejection accept if Uf(Y)/(cg(Y )); expected trials = c
Box–Muller Z = √(−2 ln U1) cos(2πU2)
Confidence interval ± tn−1,1−α/2 s/√n
Replications for target half-width nn0(h0/h*) 2
Elasticity (∂y/∂x)(x/y)
Sobol indices Si = Var(E[Y|xi ])/Var(Y); STi includes interactions

6.2 Practice questions

Short answer (2–3 marks each)

  1. Explain Kendall's notation with the example M/D/2/10.
  2. State Little's law and one condition under which it holds.
  3. Derive the inverse-transform generator for the exponential distribution.
  4. What is the expected number of trials per variate in acceptance–rejection, and why?
  5. Why must a Normal distribution not be used for service times?
  6. Distinguish local and global sensitivity analysis in one sentence each.
  7. What does a total Sobol index much larger than the first-order index indicate?

Medium answer (5 marks each)

  1. Jobs arrive at a server at 20/hour with exponential inter-arrival times; mean service time is 2.5 minutes, exponentially distributed. Find ρ, L, Lq, W and Wq, and verify Little's law.
  2. Explain the properties required of a pseudo-random number generator and describe one test used to validate one.
  3. Describe the acceptance–rejection method and apply it to f(x) = 2x on [0,1].
  4. Explain warm-up removal and the batch-means method for steady-state output analysis.
  5. Describe the Morris screening method and state what μ* and σ tell you.

Long answer (10 marks each)

  1. Discuss random variate generation in full: inverse transform (with proof), acceptance–rejection (with efficiency), convolution, composition and special methods, giving one derived example each.
  2. Explain queueing systems, Kendall's notation, Little's law and the M/M/1 results; then explain, using the Pollaczek–Khinchine formula, why variability rather than load alone drives congestion, and why simulation is needed beyond these models.
  3. Explain sensitivity analysis: purposes, local versus global methods, Sobol variance decomposition, metamodel-assisted analysis, and how results should be reported to a decision maker.
  4. Describe the complete statistical procedure for a stochastic simulation study, from input distribution fitting to reporting a defensible comparison of two system designs.

6.3 Further reading

CSEG8003 Modelling and Simulation · Unit IV student notes · Dr. Mohsin Furkh Dar · UPES